<?php
include_once 'DBConn.php';
//include_once '../util/plog/classes/plog.php';
abstract class  BaseDAO{
	
	protected  $dbConn;
//	protected  $log;
	
	function __construct() {
		$this->dbConn = new DBConn();
//		Plog::set_config(include  '/home/content/05/7086005/html/shopping/shopcarda2/sys/model/util/plog/config.php');
	}
	
	 
	
	function toArray($result, $isObj = true) {
	    $row_set = array();
	    if ($isObj) {
			while ($row = @mysql_fetch_object($result)) {
				$row_set[] = $row;
			} 
	    } else {
	    	while ($row = @mysql_fetch_row($result)) {
				$row_set[] = $row;
			} 
	    }
		@mysql_free_result($result);
		return $row_set;
	}
	
	function genInserSQL ($tableName, $arr) {
		$sql = "insert into $tableName ";
		$field = "";
		$val ="";
		foreach ($arr as $key =>$value) {
			$field.="$key,";
		
	 		if (is_string($value)) {
				$val.="'".$value."',";	
			} else {
				$val.=$value.",";
			}
		}
		return $sql.="(".substr($field,0,strlen($field)-1).") values (".substr($val, 0, strlen($val)-1).")";
	}
	
   
	protected  function open() {
		$this->dbConn->open();
	}
	
    protected function close() {
    	$this->dbConn->close();
    }
         
	function __destruct(){
	    $this->close();
	}
}
?>